﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Meraz.Core.Model;

namespace Meraz.Core.Repositories
{
    public class IssueRepository : EFRepositoryBase<Issue, int>, IIssueRepository
    {
        public IssueRepository() : base() { }
        public IssueRepository(Data.IMerazContext context) : base(context) { }

        public override Issue GetById(int id)
        {
            return context.Issues
                .Where(where1 => where1.ID == id)
                .FirstOrDefault();
        }
        public Issue GetByName(string name)
        {
            return context.Issues
                .Where(where1 => where1.Topic.Name == name)
                .FirstOrDefault();
        }

        public override void Add(Issue entity)
        {
            context.Issues.AddObject(entity);
        }

        public override void Delete(Issue entity)
        {
            context.Issues.DeleteObject(entity);
        }

        public override List<Issue> All()
        {
            return context.Issues.ToList();
        }
    }
}
